Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make clipboard(g) work #121

Merged
merged 1 commit into from
May 30, 2022

Conversation

anandijain
Copy link
Contributor

With this PR, if I have a graph in one REPL and I clipboard(g), I can paste it in another and have the same graph in both places

@etiennedeg
Copy link
Member

I agree that the current form of printing is annoying because not canonical.
I think the show function with plain/text should also be canonical, we should implement it to look something like this:

julia> path_graph(5)
{4, 3} undirected simple Int64 graph
Edge 1 => 2, Edge 2 => 3, Edge 3 => 4, Edge 4 => 5

or

julia> path_graph(5)
{4, 3} undirected simple Int64 graph
Edge 1 => 2
Edge 2 => 3
Edge 3 => 4 
Edge 4 => 5

or

julia> path_graph(5)
{4, 3} undirected simple Int64 graph
1 => [2]
2 => [1, 3]
3 => [2, 4]
4 =>[3, 5]
5 => [4]

We should implement summary to output the old behavior (currently, it output the default "SimpleGraph{Int64}", which is less satisfactory.

@codecov
Copy link

codecov bot commented May 24, 2022

Codecov Report

Merging #121 (05f0cbe) into master (da30b3b) will not change coverage.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #121   +/-   ##
=======================================
  Coverage   97.54%   97.54%           
=======================================
  Files         109      109           
  Lines        6318     6318           
=======================================
  Hits         6163     6163           
  Misses        155      155           

@simonschoelly
Copy link
Member

If I understand this pr correctly, it ensures that show(io::IO, g::AbstractSimpleGraph) just prints a form that is also a Julia statement that can be evaluated and creates a graph again? I guess that makes sense to have it that way then.

And the behavior in the repl is still the same, right? I think that one calls display(g) which in turn calls show(io, io::IO, ::MIME"text/plain"(), g)

I agree that the current form of printing is annoying because not canonical. I think the show function with plain/text should also be canonical, we should implement it to look something like this:

What exactly do you mean by canonical? That it reports all the edges? That won't work for all but very small graphs, as it would just fill the repl.

@etiennedeg
Copy link
Member

Yes, from my understanding, I think it means that two different objects should have distinct canonical expressions, so the print should display all the edges. Almost all Julia objects behave the same, for example, call show(stdout, "text/plain", collect(1:100000)), it will print the entirety of the array. This is not that much a problem because the output is automatically cropped when calling display.

Some objects don't have a strictly canonical display, for example, the "text/plain" display of a sparse matrix is the dotted representation, which is not canonical for big matrices, so I don't really know how much we need to enforce this rule.

@simonschoelly
Copy link
Member

@etiennedeg Is it ok, if we take this discussion outside of this PR and merge this one?

@etiennedeg
Copy link
Member

etiennedeg commented May 30, 2022

ok
Edit: discussion moved to #139

@simonschoelly simonschoelly merged commit 7152d54 into JuliaGraphs:master May 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants